<template>
  <el-container class="config-page panel-block">
    <el-header class="sa-header">
      <el-tabs class="sa-tabs" v-model="configType">
        <el-tab-pane v-for="c in configList" :key="c" :label="c.label" :name="c.api"></el-tab-pane>
      </el-tabs>
    </el-header>
    <basic-config v-if="configType == 'shop.admin.config.basic'" />
    <platform-config v-if="configType == 'shop.admin.config.platform'" />
    <goods-config v-if="configType == 'shop.admin.config.goods'" />
    <order-config v-if="configType == 'shop.admin.config.order'" />
    <dispatch-config v-if="configType == 'shop.admin.config.dispatch'" />
    <recharge-config v-if="configType == 'shop.admin.config.rechargewithdraw'" />
    <commission-config v-if="configType == 'shop.admin.config.commission'" />
    <pay-config v-if="configType == 'shop.admin.payconfig'"></pay-config>
  </el-container>
</template>
<script>
  export default {
    name: 'shop.admin.config',
  };
</script>
<script setup>
  import { ref, computed } from 'vue';
  import PlatformConfig from './componenets/platform/index.vue';
  import basicConfig from './componenets/basic.vue';
  import orderConfig from './componenets/order.vue';
  import goodsConfig from './componenets/goods.vue';
  import dispatchConfig from './componenets/dispatch.vue';
  import rechargeConfig from './componenets/recharge.vue';
  import CommissionConfig from './componenets/commission.vue';
  import payConfig from './componenets/payConfig/index.vue';

  import { checkAuth } from '@/sheep/directives/auth';

  const configList = computed(() => {
    const config = [
      { label: '基本信息', api: 'shop.admin.config.basic' },
      { label: '平台设置', api: 'shop.admin.config.platform' },
      { label: '订单设置', api: 'shop.admin.config.order' },
      { label: '物流设置', api: 'shop.admin.config.dispatch' },
      { label: '充值提现', api: 'shop.admin.config.rechargewithdraw' },
      { label: '分销设置', api: 'shop.admin.config.commission' },
      { label: '商品设置', api: 'shop.admin.config.goods' },
      { label: '支付设置', api: 'shop.admin.payconfig' },
    ];
    return config.filter((c) => {
      if (checkAuth(c.api)) return c;
    });
  });
  const configType = ref(configList.value.length > 0 ? configList.value[0].api : '');
</script>
